package com.apanal.qlife.common.page;

import com.apanal.qlife.common.constants.Constants;

/**
 * 公共分页实体类
 * 
 * @author shuliangxing
 * 
 * @date 2015-1-14上午10:20:01
 */
public class Page {

	public Page() {
		super();
	}

	public Page(int pageSize) {
		super();
		this.pageSize = pageSize;
	}

	/**
	 * 从第几条数据开始查询
	 */
	@SuppressWarnings("unused")
	private int start = 0;

	/**
	 * 从第几条数据结束查询
	 */
	@SuppressWarnings("unused")
	private int end = 0;

	/**
	 * 每页显示条数
	 */
	private int pageSize = Constants.DEFAULT_PAGE_SIZE;

	/**
	 * 当前第几页
	 */
	private int currentPage = 1;

	public int getStart() {
		if (this.currentPage < 1) {
			this.currentPage = 1;
		}
		return pageSize * (this.currentPage - 1);
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getEnd() {
		return pageSize * currentPage;
	}

	public void setEnd(int end) {
		this.end = end;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	@Override
	public String toString() {
		return "Page [start=" + getStart() + ", end=" + getEnd()
				+ ", pageSize=" + pageSize + ", currentPage=" + currentPage
				+ "]";
	}

}
